

*******************************Table 10 Panel A*********************************************
*******************************Table 10 Panel A*********************************************
*******************************Table 10 Panel A*********************************************


*---------------------------------------------------------------
* Panel A: Heterogenous responses (Labor Efficiency Gaps )
*---------------------------------------------------------------
cd "D:\Nanjing\2020\wage gap\Replication"
use "labor-basic-tpu-reg-1.dta",clear


bysort newid: egen indc_intensity=max(export_intensity)
drop if indc_intensity>0
* xtset newid t
 egen provyear=group(province  t)
 egen ind2year=group(ind2_adj  t)
 egen owneryear=group(QiuType  t)
 egen provowneryear=group(province QiuType  t)
 egen ind4year=group(ind4_adj  t)
 gen did_us=0
 gen did_us2=0
append using  "yong_export_us_new.dta"
*replace did=0 if indc_us==1
gen did_exp=0
replace did_exp=did*indc_intensity

gen exp_post=indc_intensity*post


gen lnabsG_gdp=ln(absG_gdp)

winsor2 tfp_op lnabsG_gdp lnage  finance2  lnkL rate , replace cuts(1 99) trim
winsor2 lnRD, replace cuts(0 99) trim
drop if VMPL<0


*------------------------------------------------------------------------------------------------------
*10.1. column 1 pre-existing us exporters
reghdfe lnabsG did_us did_exp did Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl export_intensity ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind   exp_post ///
 if indc_intensity<1&t>=2000,  ///
absorb(t newid) cluster (ind4year)   
*-----------------------------------------------------------------------------------------------------
* 10.2 column 2 firms once exporting to the us
reghdfe lnabsG did_us2 did_exp did Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl export_intensity ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind   exp_post ///
 if indc_intensity<1&t>=2000,  ///
absorb(t newid) cluster (ind4year)   

**---------------------------------------------------------------------------------------


use "labor-basic-tpu-reg-1.dta",clear

gen indc_owner=0 if QiuType==1 /*indc_owner=0 for SOEs*/
replace indc_owner=1 if QiuType==2|QiuType==3/*indc_owner==1 for nonSOEs*/

bysort ind4_adj: egen m_finance=pctile(finance2),p(75)
bysort newid: egen firm_finance=mean(finance2)
gen indc_finance=0
replace indc_finance=1 if firm_finance>m_finance /*external contrainted firms*/


gen indc_gap=0
replace indc_gap=1 if realG_gdp<0



* xtset newid t
 egen provyear=group(province  t)
 egen ind2year=group(ind2_adj  t)
 egen owneryear=group(QiuType  t)
 egen provowneryear=group(province QiuType  t)
 egen ind4year=group(ind4_adj  t)
 
 gen did_owner=did*indc_owner
gen did_fin=did*indc_finance
gen did_gap=did*indc_gap
gen lnabsG_gdp=ln(absG_gdp)


winsor2 tfp_op lnabsG_gdp lnage  finance2  lnkL rate , replace cuts(1 99) trim
winsor2 lnRD, replace cuts(0 99) trim
drop if VMPL<0
*--------------------------------------------------------------------------------------------------
*10.3: column 3 Soe vs. nonSOE
reghdfe lnabsG_gdp did_owner did Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl export_intensity ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind,    ///
absorb(t newid) cluster (ind4year)   
*--------------------------------------------------------------------------------------------------
* 10.4 column 4 financially constrainted and non-constrainted firms
reghdfe lnabsG_gdp did_fin did Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl export_intensity  ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind,    ///
absorb(t newid) cluster (ind4year)   
*--------------------------------------------------------------------------------------------------
* 10.5 column 5 firms with negative and positive gap
reghdfe lnabsG_gdp did_gap did Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl export_intensity indc_gap ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind,    ///
absorb(t newid) cluster (ind4year)   












*******************************Table 10 Panel B*********************************************
*******************************Table 10 Panel B*********************************************
*******************************Table 10 Panel B*********************************************


*---------------------------------------------------------------
* Panel B: Heterogenous responses (Capital Efficiency Gaps )
*---------------------------------------------------------------





cd "D:\Nanjing\2020\wage gap\Replication"
use "labor-basic-tpu-reg-1.dta",clear


gen VMPK=capitale*(y_ind_add1/k)



*1. generate capital category:
bysort id: gen indc_n=_n==1
gen m_k=k if indc_n==1
bysort id: egen M_k=max(m_k)

egen p1=pctile(M_k), p(25)
egen p2=pctile(M_k), p(50)
egen p3=pctile(M_k), p(75)
gen size_k=0
replace size_k=1 if M_k<=p1
replace size_k=2 if M_k>p1&M_k<p2
replace size_k=3 if M_k>p2&M_k<p3
replace size_k=4 if M_k>p3

 bysort t indc: egen agg_l=sum(n)
 gen l_s=n/agg_l
 
*2. generate average rental rate in each category:
bysort city ind4_adj QiuType size_k t: egen r_rate=sum(l_s*VMPK) if inv>0
*bysort county ind4_adj QiuType size_k t: egen r_rate=mean(VMPK) if inv>0


* 3. gap measured in capital:

gen gdp_def=1
replace gdp_def=1.077 if t==1999
replace gdp_def=1.077*1.085 if t==2000
replace gdp_def=1.077*1.085*1.083 if t==2001
replace gdp_def=1.077*1.085*1.083*1.091 if t==2002
replace gdp_def=1.077*1.085*1.083*1.091*1.10 if t==2003
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201 if t==2004
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114 if t==2005
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114*1.127 if t==2006
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114*1.127*1.142 if t==2007

/*
gen gdp_def=1
replace gdp_def=1.063 if t==1999
replace gdp_def=1.177 if t==2000
replace gdp_def=1.302 if t==2001
replace gdp_def=1.428 if t==2002
replace gdp_def=1.819 if t==2003
replace gdp_def=1.899 if t==2004
replace gdp_def=2.198 if t==2005
replace gdp_def=2.575 if t==2006
replace gdp_def=3.170 if t==2007
*/

gen gap_k=VMPK-r_rate
gen abs_G_k=abs(gap_k)
gen lnabs_k=log(abs_G_k)


bysort newid: egen indc_intensity=max(export_intensity)
drop if indc_intensity>0|indc_intensity==1
* xtset newid t
 egen provyear=group(province  t)
 egen ind2year=group(ind2_adj  t)
 egen owneryear=group(QiuType  t)
 egen provowneryear=group(province QiuType  t)
 egen ind4year=group(ind4_adj  t)
 gen did_us=0
 gen did_us2=0
append using  "yong_export_us_capital.dta"
*replace did=0 if indc_us==1
gen did_exp=0
replace did_exp=did*indc_intensity


gen exp_post=indc_intensity*post


gen lnabsG_gdp=ln(absG_gdp)

winsor2 tfp_op lnabs_k lnage  finance2  lnkL rate , replace cuts(1 99) trim
winsor2 lnRD, replace cuts(0 99) trim
*drop if VMPL<0


*---------------------------------
*10.1  column 1 pre-existing us exporters
reghdfe lnabs_k did_us did_exp did Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl export_intensity ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind   exp_post  ///
 if indc_intensity<1&t>=2000,  ///
absorb(t newid) cluster (ind4year)   

* 10.2 column 2
reghdfe lnabs_k did_us2 did_exp did Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl export_intensity ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind   exp_post ///
 if indc_intensity<1&t>=2000,  ///
absorb(t newid) cluster (ind4year)     


**---------------------------------------------------------------------------------------
use "labor-basic-tpu-reg-1.dta",clear
gen VMPK=capitale*(y_ind_add1/k)



*1. generate capital category:
bysort id: gen indc_n=_n==1
gen m_k=k if indc_n==1
bysort id: egen M_k=max(m_k)

egen p1=pctile(M_k), p(25)
egen p2=pctile(M_k), p(50)
egen p3=pctile(M_k), p(75)
gen size_k=0
replace size_k=1 if M_k<=p1
replace size_k=2 if M_k>p1&M_k<p2
replace size_k=3 if M_k>p2&M_k<p3
replace size_k=4 if M_k>p3

 bysort t indc: egen agg_l=sum(n)
 gen l_s=n/agg_l
 
*2. generate average rental rate in each category:
bysort city ind4_adj QiuType size_k t: egen r_rate=sum(l_s*VMPK)
*bysort county ind4_adj QiuType size_k t: egen r_rate=mean(VMPK) if inv>0


* 3. gap measured in capital:

gen gdp_def=1
replace gdp_def=1.077 if t==1999
replace gdp_def=1.077*1.085 if t==2000
replace gdp_def=1.077*1.085*1.083 if t==2001
replace gdp_def=1.077*1.085*1.083*1.091 if t==2002
replace gdp_def=1.077*1.085*1.083*1.091*1.10 if t==2003
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201 if t==2004
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114 if t==2005
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114*1.127 if t==2006
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114*1.127*1.142 if t==2007

/*
gen gdp_def=1
replace gdp_def=1.063 if t==1999
replace gdp_def=1.177 if t==2000
replace gdp_def=1.302 if t==2001
replace gdp_def=1.428 if t==2002
replace gdp_def=1.819 if t==2003
replace gdp_def=1.899 if t==2004
replace gdp_def=2.198 if t==2005
replace gdp_def=2.575 if t==2006
replace gdp_def=3.170 if t==2007
*/

gen gap_k=VMPK-r_rate
gen abs_G_k=abs(gap_k)
gen lnabs_k=log(abs_G_k)



gen indc_owner=0 
replace indc_owner=1 if QiuType==2

bysort ind4_adj: egen m_finance=pctile(finance2),p(50)
bysort newid: egen firm_finance=mean(finance2)
gen indc_finance=0
replace indc_finance=1 if firm_finance<m_finance /*external contrainted firms*/


cap drop indc_gap
gen indc_gap=0
replace indc_gap=1 if realG_gdp<0|gap_k<0
bysort newid: egen indc_gap2=max(indc_gap)
replace indc_gap=indc_gap2


* xtset newid t
 egen provyear=group(province  t)
 egen ind2year=group(ind2_adj  t)
 egen owneryear=group(QiuType  t)
 egen provowneryear=group(province QiuType  t)
 egen ind4year=group(ind4_adj  t)
 
 gen did_owner=did*indc_owner
gen did_fin=did*indc_finance
gen did_gap=did*indc_gap
gen lnabsG_gdp=ln(absG_gdp)
gen owner_post=indc_owner*post


winsor2 tfp_op lnabsG_gdp lnabs_k lnage  finance2  lnkL rate , replace cuts(1 99) trim
winsor2 lnRD, replace cuts(0 99) trim
drop if VMPL<0
drop if export_intensity==1

*10.3: column 3 Soe vs. nonSOE
reghdfe lnabs_k did_owner did Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl export_intensity ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind ,    ///
absorb(t newid) cluster (ind4year)   
*--------------------------------------------------------------------------------------------------
* 10.4 column 4 financially constrainted and non-constrainted firms
reghdfe lnabs_k did_fin did Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl export_intensity  ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind,    ///
absorb(t newid) cluster (ind4year)   
*--------------------------------------------------------------------------------------------------

*10.5 column 5 firms with negative and positive gap
reghdfe lnabs_k did_gap did Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl export_intensity indc_gap ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind,    ///
absorb(t newid) cluster (ind4year)  





